<script>
      jQuery("a[rel^='prettyPhoto']").prettyPhoto({
            theme:'facebook',
            default_height:100,
            keyboard_shortcuts: false
        });
        function set_size(){
        var size = jQuery("#result").height();
        size = size+50;
        jQuery(".pp_content").attr('style','height:'+size+'px');
    }
    stFacebookToolbox.sortColumn();
        </script>
        <style>
            th.column-CouponTemplateID {
               width:40px; 
            }
        </style>
<div class="w100p bgl">
    <div class="w100p bgr">
        <div class="inner_container gallery1">
      
            <table class="widefat" cellspacing="0" style="width: 60%;">
                <thead>
                    
                    <tr style="">
                        <th style="border: none">Statistics</th>                          
                        <th style="text-align: center;width: 60px; text-align: center; border-bottom: 0; border-top: 0;"></th> 
                    </tr>
                    <tr>
                                               
                    </tr>
                </thead>
                <tbody>
                    <tr class="bg_gray1">
                        <td style="font-weight: bold">Total number of coupon generated:</td>
                        <td style="border-right: 1px solid #fff" ><p><?php echo $number_coupon; ?></p></td>  
                      
                    </tr>                    
                    <tr class="bg_gray2">
                        <td style="font-weight: bold">Total number of sales:</td>
                        <td style="border-right: 1px solid #fff"><p><?php echo $number_sales;  ?></p></td>
                       
                    </tr>
                    <tr class="bg_gray1">
                        <td style="font-weight: bold">Total sales value:</td>
                        <td style="border-right: 1px solid #fff"><p><?php echo empty($total_user)? 0:$total_user  ?></p></td>
                        
                    </tr>
                     <tr class="bg_gray1">
                        <td style="font-weight: bold">Referred customers:</td>
                        <td style="border-right: 1px solid #fff"><p><?php echo empty($referer_coupon)? 0:$referer_coupon  ?> (<?php echo ($number_coupon > 0)?round($referer_coupon/$number_coupon,2)*100:'0';?>%)</p></td>
                        
                    </tr>
                   
                    
                </tbody>
            </table>
            <p></p>
            <table class="widefat" cellspacing="0">
                <thead>
                    <tr>
                        <?php print_column_headers('stFacebookToolbox_stFacebookToolbox'); ?>
                    </tr>
                </thead>

                <tbody>
                <?php
                if (count($results) > 0) {
                    
                    $tr_class = "";
                    $upload_data = wp_upload_dir();
                    foreach ($results as $result) {
                        $array = explode('-',substr($result->CouponGeneratedDateTime,0,11));
                        
                        $datetime = $array[2].'.'.$array[1].'.'.$array[0].' '.substr($result->CouponGeneratedDateTime,11);
                       // $description  = (strlen($result->CouponTemplateDescription) > 35)?substr($result->CouponTemplateDescription,0,35).'...':$result->CouponTemplateDescription;
                        if( empty($tr_class) || $tr_class == "class='bg_gray2'"){
                            $tr_class = "class='bg_gray1'";
                        }else{
                            $tr_class = "class='bg_gray2'";
                        }
                        echo "<tr id='$result->CouponTemplateID' $tr_class  >"
                        . "<td>" 
                        . $result->CouponTemplateID
                        . "</td>"
                        . "<td>"
                        . $result->CouponTemplateName
                        . "<div class=\"row-actions short_action\">"
                        . "<span  short_action='' style='cursor:pointer;' id='' action='' class='edit'  onclick='jQuery.prettyPhoto.loadPage(\"coupon_user_statistics&template_id=$result->CouponTemplateID\",null,null,function(){set_size();});'>View customer</span>"
                        . "</div>"
                        . "</td>"
                        . "<td>"
                        . $model->get_coupon($result->CouponTemplateID)
                        . "</td>"
                        . "<td>"
                        . $model->get_sales($result->CouponTemplateID)
                        . "</td>"
                        . "</tr>"
                        ;
                    }
                }
                ?>
                </tbody>
            </table>
            <div class="page_d">
                <?php echo $pagination?>
                <div class="cl"></div>
            </div>
            
        </div>
    </div>
</div>